<?php
session_start();
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/database.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/functions.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/class.admin.php');
$admin = new admin();
$admin->canView($_SERVER['PHP_SELF']);
ob_start("sanitize_output"); 
$rows=$admin->showForms(); // it's in $pages['results'];
?>
<h2 class="form-heading">Current Forms</h2>
<table width="99%" class="headed-table">
	<thead>
    <tr valign="top">
    <td width="1%" class="hleft"></td>
    <td width="25%"><h6>&nbsp;Form name</h6></td>
	<td width="10%"><h6>&nbsp;Enctype</h6></td>
    <td width="10%"><h6>&nbsp;Method</h6></td>
	<td width="45%"><h6>&nbsp;Code</h6></td>
    <td width="5%" class="hright"></td>
</tr>
</thead>
<tbody>
<?php
$i=0; 
foreach($rows['results'] as $row) {
$bg=($i%2) ? ' odd' : '';
$val='[form]{&quot;token&quot;:&quot;'.$row['token'].'&quot;}[/form]';
echo('<tr valign="top">');
	echo('<td class="left'.$bg.'" width="1%"></td>');
	echo('<td class="'.$bg.'" width="25%">'.$row['form_name'].'</td>');
	echo('<td class="'.$bg.'" width="10%">'.$row['enctype'].'</td>');
	echo('<td class="'.$bg.'" width="10%">'.$row['method'].'</td>');
	echo('<td class="'.$bg.'" width="45%"><input type="text" value="'.$val.'" class="form-field" style="font-weight:bold" /></td>');
	echo('<td class="right'.$bg.'" width="5%" style="text-align:right;"><a href="/admin/resources/php/requests/forms/edit-form.php?id='.(string)$row['_id'].'" class="form-edit"><img src="/admin/resources/images/b_edit.png" /></a></td>');
echo('</tr>');

}
?>

</tbody>
</table>
